using System;
using System.ComponentModel;
using System.Drawing;
using System.Text.RegularExpressions;
using System.Windows.Forms;

namespace ICP_MS.Plugin.Experiment;

public class FormExport : Form
{
	public string FilePath = "";

	public bool ShowConc = true;

	public bool ShowUcps = true;

	public bool ShowIcps = true;

	public bool ShowRatio = false;

	private IContainer components = null;

	private CheckBox chkCPS;

	private CheckBox chkUCPS;

	private CheckBox chkConc;

	private Button buttonOK;

	private CheckBox checkBoxRatio;

	private TextBox textBoxPath;

	private Button buttonChoose;

	private Button buttonCancel;

	public FormExport(string _filePath)
	{
		InitializeComponent();
		FilePath = _filePath;
		textBoxPath.Text = _filePath;
	}

	private bool IsPath(string SavePath)
	{
		Regex regex = new Regex("^([a-zA-Z]:\\\\)[^\\/\\:\\*\\?\\\"\\<\\>\\|\\,]+$");
		return regex.IsMatch(SavePath);
	}

	private void FormExport_Load(object sender, EventArgs e)
	{
		ApplyResources();
	}

	private void ApplyResources()
	{
		Text = Lang.Txt("FormInstrumentCalibration.Export.Text");
		chkConc.Text = Lang.Txt("AddFormExport.Concentration");
		chkUCPS.Text = Lang.Txt("AddFormExport.OriginalIntensity");
		chkCPS.Text = Lang.Txt("AddFormExport.CorrectionIntensity");
		checkBoxRatio.Text = Lang.Txt("AddFormExport.Ratio");
		buttonOK.Text = Lang.Txt("AddFormExport.OK");
		buttonCancel.Text = Lang.Txt("AddFormExport.Cancel");
	}

	private void buttonOK_Click(object sender, EventArgs e)
	{
		if (!IsPath(textBoxPath.Text))
		{
			MessageBox.Show(Lang.Txt("AddFormExport.BtnOKMessege"));
			return;
		}
		ShowConc = chkConc.Checked;
		ShowUcps = chkUCPS.Checked;
		ShowIcps = chkCPS.Checked;
		ShowRatio = checkBoxRatio.Checked;
		base.DialogResult = DialogResult.OK;
	}

	private void buttonCancel_Click(object sender, EventArgs e)
	{
		base.DialogResult = DialogResult.Cancel;
	}

	private void buttonChoose_Click(object sender, EventArgs e)
	{
		SaveFileDialog saveDialog = new SaveFileDialog();
		saveDialog.DefaultExt = "xlsx";
		saveDialog.Filter = "Excel文件|*.xlsx";
		saveDialog.FileName = FilePath;
		if (saveDialog.ShowDialog() == DialogResult.OK)
		{
			FilePath = saveDialog.FileName;
			textBoxPath.Text = FilePath;
		}
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.chkCPS = new System.Windows.Forms.CheckBox();
		this.chkUCPS = new System.Windows.Forms.CheckBox();
		this.chkConc = new System.Windows.Forms.CheckBox();
		this.buttonOK = new System.Windows.Forms.Button();
		this.checkBoxRatio = new System.Windows.Forms.CheckBox();
		this.textBoxPath = new System.Windows.Forms.TextBox();
		this.buttonChoose = new System.Windows.Forms.Button();
		this.buttonCancel = new System.Windows.Forms.Button();
		base.SuspendLayout();
		this.chkCPS.AutoSize = true;
		this.chkCPS.Checked = true;
		this.chkCPS.CheckState = System.Windows.Forms.CheckState.Checked;
		this.chkCPS.Location = new System.Drawing.Point(301, 39);
		this.chkCPS.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.chkCPS.Name = "chkCPS";
		this.chkCPS.Size = new System.Drawing.Size(89, 19);
		this.chkCPS.TabIndex = 8;
		this.chkCPS.Text = "校正强度";
		this.chkCPS.UseVisualStyleBackColor = true;
		this.chkUCPS.AutoSize = true;
		this.chkUCPS.Checked = true;
		this.chkUCPS.CheckState = System.Windows.Forms.CheckState.Checked;
		this.chkUCPS.Location = new System.Drawing.Point(168, 39);
		this.chkUCPS.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.chkUCPS.Name = "chkUCPS";
		this.chkUCPS.Size = new System.Drawing.Size(89, 19);
		this.chkUCPS.TabIndex = 7;
		this.chkUCPS.Text = "原始强度";
		this.chkUCPS.UseVisualStyleBackColor = true;
		this.chkConc.AutoSize = true;
		this.chkConc.Checked = true;
		this.chkConc.CheckState = System.Windows.Forms.CheckState.Checked;
		this.chkConc.Location = new System.Drawing.Point(39, 39);
		this.chkConc.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.chkConc.Name = "chkConc";
		this.chkConc.Size = new System.Drawing.Size(89, 19);
		this.chkConc.TabIndex = 6;
		this.chkConc.Text = "计算浓度";
		this.chkConc.UseVisualStyleBackColor = true;
		this.buttonOK.Location = new System.Drawing.Point(123, 150);
		this.buttonOK.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.buttonOK.Name = "buttonOK";
		this.buttonOK.Size = new System.Drawing.Size(100, 29);
		this.buttonOK.TabIndex = 9;
		this.buttonOK.Text = "确定";
		this.buttonOK.UseVisualStyleBackColor = true;
		this.buttonOK.Click += new System.EventHandler(buttonOK_Click);
		this.checkBoxRatio.AutoSize = true;
		this.checkBoxRatio.Location = new System.Drawing.Point(436, 39);
		this.checkBoxRatio.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.checkBoxRatio.Name = "checkBoxRatio";
		this.checkBoxRatio.Size = new System.Drawing.Size(59, 19);
		this.checkBoxRatio.TabIndex = 10;
		this.checkBoxRatio.Text = "比率";
		this.checkBoxRatio.UseVisualStyleBackColor = true;
		this.textBoxPath.Location = new System.Drawing.Point(35, 91);
		this.textBoxPath.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.textBoxPath.Name = "textBoxPath";
		this.textBoxPath.Size = new System.Drawing.Size(388, 25);
		this.textBoxPath.TabIndex = 11;
		this.buttonChoose.Location = new System.Drawing.Point(437, 90);
		this.buttonChoose.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.buttonChoose.Name = "buttonChoose";
		this.buttonChoose.Size = new System.Drawing.Size(56, 29);
		this.buttonChoose.TabIndex = 12;
		this.buttonChoose.Text = "...";
		this.buttonChoose.UseVisualStyleBackColor = true;
		this.buttonChoose.Click += new System.EventHandler(buttonChoose_Click);
		this.buttonCancel.Location = new System.Drawing.Point(324, 150);
		this.buttonCancel.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		this.buttonCancel.Name = "buttonCancel";
		this.buttonCancel.Size = new System.Drawing.Size(100, 29);
		this.buttonCancel.TabIndex = 13;
		this.buttonCancel.Text = "取消";
		this.buttonCancel.UseVisualStyleBackColor = true;
		this.buttonCancel.Click += new System.EventHandler(buttonCancel_Click);
		base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 15f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(536, 200);
		base.Controls.Add(this.buttonCancel);
		base.Controls.Add(this.buttonChoose);
		base.Controls.Add(this.textBoxPath);
		base.Controls.Add(this.checkBoxRatio);
		base.Controls.Add(this.buttonOK);
		base.Controls.Add(this.chkCPS);
		base.Controls.Add(this.chkUCPS);
		base.Controls.Add(this.chkConc);
		base.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
		base.Margin = new System.Windows.Forms.Padding(4, 4, 4, 4);
		base.Name = "FormExport";
		base.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
		this.Text = "导出";
		base.Load += new System.EventHandler(FormExport_Load);
		base.ResumeLayout(false);
		base.PerformLayout();
	}
}
